package com.hqq.behaviour.feature_toggle;

import java.util.ArrayList;
import java.util.List;

/**
 * UserGroup
 * Created by heqianqian on 2017/6/21.
 */
public class UserGroup {

    private static List<User> freeGroup = new ArrayList<>();
    private static List<User> paidGroup = new ArrayList<>();


    public static void addToPaidGroup(User user) throws IllegalArgumentException {
        if (freeGroup.contains(user)) {
            throw new IllegalArgumentException("User already exists in freeGroup");
        } else {
            if (!paidGroup.contains(user)) {
                paidGroup.add(user);
            }
        }
    }

    public static void addToFreeGroup(User user) throws IllegalArgumentException {
        if (paidGroup.contains(user)) {
            throw new IllegalArgumentException("User already exists in paidGroup");
        } else {
            if (!freeGroup.contains(user)) {
                freeGroup.add(user);
            }
        }
    }

    public static boolean isPaid(User user) {
        return paidGroup.contains(user);
    }
}


